#if !defined(ximera_plugins_dinput8_inputsystem_hpp)
#define ximera_plugins_dinput8_inputsystem_hpp

#include <ximera/input/iinputsystem.hpp>
#include <ximera/system/application.hpp>
#include <ximera/common/sharedobject.hpp>
#include <ximera/threading/thread.hpp>
#include <ximera/threading/messagequeue.hpp>

#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>

// -----------------------------------------------------------

namespace ximera { namespace input { namespace dinput8
{
    class XIMERA_PLUGIN_API InputSystem : public input::IInputSystem
    {
    public:
        InputSystem(system::Application& app);

        virtual ~InputSystem();

        /*! Called to update the status of the input system. */
        virtual void update();

        /*! Returns a SharedPtr to a IDevice interface.
            \param deviceType The type of device that is wanted. */
        virtual SharedPtr<input::IDevice> device(input::DeviceType const& deviceType);

        /*! Returns a SharedPtr to a IKeyboard interface. */
        virtual SharedPtr<input::IKeyboard> keyboard();

        /*! Returns a SharedPtr to a IMouse interface. */
        virtual SharedPtr<input::IMouse> mouse();

    private:
        SharedPtr<threading::MessageQueue> _msgqueue;

        SharedObject<IDirectInput8> _dinput;
        std::vector<SharedPtr<input::IDevice> > _devices;
        SharedPtr<input::IKeyboard> _keyboard;
        SharedPtr<input::IMouse> _mouse;

        HWND _hwnd;
    };
}}}

// -----------------------------------------------------------

#endif